package com.example.demo.yjcx.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.utils.BigDecimalUtils;
import com.example.demo.utils.JsonUtil;
import com.example.demo.yjcx.dao.BasePriceDO;
import com.example.demo.yjcx.dao.BasePriceMapper;
import com.example.demo.yjcx.model.BasePriceBO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author linjingze
 * @date 2023/12/21 9:29 AM
 */
@Service
public class BasePriceService {

    @Autowired
    private BasePriceMapper basePriceMapper;

    @Transactional(rollbackFor = Exception.class)
    public void upsertBasePrice(List<BasePriceDO> basePriceList) {
        basePriceList.forEach(s -> {
            if (s.getId() == null) {
                basePriceMapper.insert(s);
            } else {
                basePriceMapper.updateById(s);
            }
        });
    }


    public List<BasePriceDO>  listBasePrice() {
        return basePriceMapper.selectList(new QueryWrapper<>());
    }





}
